#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "task.h"

void *use_longtime_work(void *arg)
{
    int sleep_time = *(int *)arg;
    printf("use_longtime_work: %d s\n", sleep_time);
    sleep(sleep_time);
    printf("use_longtime_work_finish %d s!\n", sleep_time);
    return NULL;
}

int main()
{
    int job_times[] = {30, 50, 80, 120, 30};
    for (size_t i = 0; i < sizeof(job_times) / sizeof(int); i++)
    {
        uint32_t job_id = task_init(use_longtime_work, &(job_times[i]));
        if (job_id < TASK_MAX)
            printf("[%ld]: will used %ds job_id:%d\n", i, job_times[i], job_id);
        else
        {
            printf("task pool(%d) full!\n", job_id);
        }
    }
    task_exit();
    exit(0);
}